Skip to content

Quick-add ボタンにアクティブエディタのファイルをリアルタイム表示#49

Merged
ktmage merged 3 commits into
developmentfrom
feature/40/quick-add-active-editor
Mar 1, 2026
Merged

Quick-add ボタンにアクティブエディタのファイルをリアルタイム表示#49
ktmage merged 3 commits into
developmentfrom
feature/40/quick-add-active-editor

Conversation

@ktmage

@ktmage ktmage commented Mar 1, 2026

Copy link
Copy Markdown
Owner

対応 Issue

closes #40

概要

入力エリアの quick-add ボタンに、VS Code で現在アクティブなエディタのファイルをリアルタイムで反映するようにした。

やったこと

  • 拡張側で vscode.window.onDidChangeActiveTextEditor リスナーを追加し、アクティブエディタが変わるたびに activeEditor メッセージを Webview に送信
  • Webview 初期化時(ready メッセージのハンドラ)でも初期アクティブエディタを送信
  • activeEditor メッセージ型を ExtToWebviewMessage に追加(拡張側・Webview 側の両方)
  • App.tsx に activeEditorFile ステートを追加し、activeEditor メッセージで更新
  • InputArea で openEditors[0] の固定表示をやめ、props から渡される activeEditorFile を使用

やらなかったこと

  • openEditors メッセージの廃止(ファイルピッカーで引き続き使用)
  • アクティブエディタが null の場合に openEditors[0] へフォールバックする処理(null ならボタン非表示)

変更ファイル

ファイル 変更内容
src/chat-view-provider.ts activeEditor メッセージ型追加、onDidChangeActiveTextEditor リスナー登録、getActiveEditorFile メソッド追加
webview/vscode-api.ts activeEditor メッセージ型追加
webview/App.tsx activeEditorFile ステート追加、メッセージハンドリング追加
webview/components/organisms/InputArea/InputArea.tsx activeEditorFile を props から受け取り、openEditors[0] の固定表示を削除
webview/__tests__/scenarios/07-file-context.test.tsx activeEditor メッセージ対応、リアルタイム更新テスト追加

確認方法

  1. VS Code でファイルを開いた状態で拡張機能のチャットパネルを確認
  2. quick-add ボタンに現在アクティブなファイル名が表示されることを確認
  3. 別のタブに切り替えると、ボタンの表示がリアルタイムに更新されることを確認
  4. すべてのエディタを閉じると、ボタンが非表示になることを確認

ktmage added 3 commits March 1, 2026 23:35
Add onDidChangeActiveTextEditor listener in extension host to push
activeEditor messages to webview. Send initial activeEditor on ready.
Add activeEditor type to ExtToWebviewMessage in both extension and
webview protocol definitions.
Replace openEditors[0] with activeEditorFile state in InputArea.
App.tsx handles activeEditor messages and passes the file to InputArea
via props. Quick-add button now reflects the actual active editor.
Update setupWithFiles to send activeEditor message. Add tests for
real-time quick-add button update via activeEditor message and
null activeEditor hiding the quick-add button.
@ktmage ktmage merged commit f37a101 into development Mar 1, 2026
1 check passed
@ktmage ktmage mentioned this pull request Mar 1, 2026
@ktmage ktmage deleted the feature/40/quick-add-active-editor branch March 1, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant